1 00:00:00,860 --> 00:00:02,360 Welcome in this video. 2 00:00:02,360 --> 00:00:04,760 It's going to be a really simple practice activity. 3 00:00:04,880 --> 00:00:09,890 So I'd like for you to create a script that changes the colors of a bunch of parts that are part of 4 00:00:09,890 --> 00:00:13,610 a disco four So you can create like a disco four effect. 5 00:00:13,940 --> 00:00:18,440 I want you to change the colors every 2 seconds, and the colors can be whatever you want. 6 00:00:18,440 --> 00:00:20,480 Just make them random each time. 7 00:00:21,140 --> 00:00:27,020 Just note that you have to use the get children function in order to grab all the children of an instance. 8 00:00:27,020 --> 00:00:32,000 In this case, I have provided a model and it's full of a bunch of parts, so you'll have to use the 9 00:00:32,000 --> 00:00:35,990 get children function on the disco floor in order to grab all the parts. 10 00:00:36,500 --> 00:00:41,060 So please spend one or 2 minutes to create a script to change the color of the parts, and I'll show 11 00:00:41,060 --> 00:00:42,530 you my solution next. 12 00:00:44,950 --> 00:00:49,150 So the first thing I want to do is get a reference to the model that is holding all the parts for the 13 00:00:49,150 --> 00:00:50,030 disco floor. 14 00:00:50,050 --> 00:00:52,330 So I'll just create a variable called for. 15 00:00:52,810 --> 00:00:54,550 And then I'll do script parent. 16 00:00:54,550 --> 00:00:56,050 And now I have my reference. 17 00:00:56,500 --> 00:01:00,220 The next thing I want to do is to create a new random data type. 18 00:01:00,580 --> 00:01:04,930 So that way I can generate random numbers to make random colors for my parts. 19 00:01:05,870 --> 00:01:09,500 The next thing I want to do is create a while loop that runs forever. 20 00:01:10,270 --> 00:01:15,040 And inside my while loop I'll create a for loop to loop through all the parts that are a part of my 21 00:01:15,040 --> 00:01:18,130 disco four so I can change the color for every single one of them. 22 00:01:20,070 --> 00:01:24,900 And then I'll pass my four model and I'll usually get children function to grab all the children of 23 00:01:24,900 --> 00:01:25,620 the four. 24 00:01:29,660 --> 00:01:31,180 Now this part is important. 25 00:01:31,190 --> 00:01:35,810 I need to check whether or not the child I'm grabbing from my floor is a bass part. 26 00:01:36,230 --> 00:01:41,210 Because since my script is in here, if I loop through here, one of these objects is inevitably going 27 00:01:41,210 --> 00:01:43,780 to be the script and I can't change the color of the script. 28 00:01:43,790 --> 00:01:48,320 So that's why we have this if statement here to check whether or not the item we are looking at is a 29 00:01:48,320 --> 00:01:49,040 bass part. 30 00:01:51,090 --> 00:01:54,540 If it is, then we can change the colour of a part to a new colour. 31 00:01:54,540 --> 00:01:55,530 Three value. 32 00:01:56,970 --> 00:02:04,050 From rugby and then we'll pass the rag object and use the next integer function and pass a number from 33 00:02:04,050 --> 00:02:06,630 0 to 255. 34 00:02:06,840 --> 00:02:11,640 And then I'll just copy this and paste it two more times. 35 00:02:11,940 --> 00:02:13,590 So now we get a random color. 36 00:02:14,190 --> 00:02:19,170 Last thing I need to make sure I do is yield the script for 2 seconds. 37 00:02:19,740 --> 00:02:21,240 So that way my game doesn't crash. 38 00:02:21,240 --> 00:02:24,360 And that way the four only changes colors every 2 seconds. 39 00:02:25,450 --> 00:02:29,500 Now I should be able to run my game and see my disco for change colors. 40 00:02:33,060 --> 00:02:33,930 Perfect. 41 00:02:34,820 --> 00:02:37,040 We have our nice, cool little disco for.